﻿using System;
using System.Collections.Generic;
using System.Text;
using System.CodeDom.Compiler;
using Microsoft.CSharp;
using System.Web.Services.Description;
using System.Net;
using System.IO;
using System.CodeDom;
using Common.Logging;
using Utility;
using Model.TransfersConfig;
using AppToolKit.Core.Context.Spring;


namespace BLL.Action.Transfer.WebService
{
    public class WebServiceHelper
    {
       static ILog log = LogManager.GetLogger(LogDefault.AppError);
       [AutoWiring]
       public AuthorParser Parser { get; set; }
      
        #region InvokeWebService
        //动态调用web服务
       public object InvokeWebService(string url, string strSql,object tag)
        {
            return InvokeWebService1(url, strSql);
        }

       private  object InvokeWebService1(string url, string strSql)
        {

            try
            {
               

               wsInterface ws = new wsInterface(url);
              
               ws.ReportSoapHeaderValue = SetAuthor(typeof(wsInterface)) as ReportSoapHeader;

               return ws.GetData(strSql);
                    

            }
            catch (Exception ex)
            {
               
                log.Debug(string.Format(" ERROR:{0},{1},{2}", url, strSql, ex));
                throw new Exception(ex.InnerException.Message, new Exception(ex.InnerException.StackTrace));
            }
        }
       
       public object SetAuthor(Type type)
        {
           
           return  Parser.GetSoapHeader(type);
           

        }
        #endregion
    }
}
